package com.naiterui.ehp.bs.doctor.dao.impl;

import com.naiterui.ehp.bp.domain.BannerInfo;
import com.naiterui.ehp.bp.utils.date.DateUtil;
import com.naiterui.ehp.bs.doctor.dao.IBannerInfoDao;
import com.naiterui.ehp.bs.doctor.repository.IBannerInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * banner信息Dao
 *
 * @since 2.0.0
 */
@Component
public class AdBannerInfoDaoImpl  implements IBannerInfoDao {

    @Autowired
    private IBannerInfoRepository bannerInfoRepository;

    /**
     * 根据banner展示轮播量获取banner集合 IBannerInfoDao.getBannerInfo()
     */
    @Override
    public List<BannerInfo> getBannerInfo() {

        return bannerInfoRepository.getBannerInfo(DateUtil.getCurrentDate(), DateUtil.getCurrentDate());
    }

    /**
     * 获取浮层活动banner
     *
     * @return
     */
    @Override
    public BannerInfo getLayerInfo() {
        List<BannerInfo> resultList = bannerInfoRepository.getLayerInfo(DateUtil.getCurrentDate(), DateUtil.getCurrentDate());
        return resultList.isEmpty() ? null : resultList.get(0);
    }

    @Override
    public List<BannerInfo> getBannerByType(Integer bannerType) {
        return bannerInfoRepository.getBannerByType(bannerType, DateUtil.getCurrentDate(), DateUtil.getCurrentDate());
    }
}
